#ifndef _E_EVENT_SHAPE_H_
#define _E_EVENT_SHAPE_H_

#include "EShape.h"
#include "EGameObject.h"

#include "eH.h"
namespace engine
{

class EEntity;
class EPhActor;
class EPhScene;

//------------------------------------------------------------
class EEventShape
{
  enum _eRegisteredEntityState
  {
    REGISTERED_ENTITY_STATE_OUTSIDE = 0,
    REGISTERED_ENTITY_STATE_INSIDE,
  };
  class ERegisteredEntityData
  {
  public:
    ERegisteredEntityData();
    ERegisteredEntityData( EEntity& entity, void *pUserData);
    EEntity*                  m_pEntity;
    void*                     m_pUserData;
    _eRegisteredEntityState   m_eState;
    void operator=(const ERegisteredEntityData& data);
  };
  typedef map<EEntity*, ERegisteredEntityData>  ERegisteredEntityMap;
  flag16                        m_flagShapeEventTypes;
  ERegisteredEntityMap          m_mapEntities;
  EPhActor*                     m_pPhActor;
  EShape                        m_Shape;
public:
  enum _eShapeEventType
  {
    SHAPE_EVENT_ENTER               = 0x0001,
    SHAPE_EVENT_IS_STILL_INSIDE     = 0x0002,
    SHAPE_EVENT_LEAVE               = 0x0004,
    SHAPE_EVENT_ENTER_FIRST_TIME    = 0x0008,
    SHAPE_EVENT_EXIT_FIRST_TIME     = 0x0010,
    SHAPE_EVENT_ALL                 = 0xffff,
  };

  EEventShape( const EBoxShape& shape, flag16 flagActivatedEventTypes = EEventShape::SHAPE_EVENT_ALL );
  virtual ~EEventShape();

  inline void  setEnabledShapeEventType   ( _eShapeEventType eEventType, bool bEnabled );
  inline bool  isShapeEventTypeEnabled    ( _eShapeEventType eEventType );
  inline void  registerEntity             ( EEntity& entity, void *pUserData = NULL );
  inline void  unregisterEntity           ( EEntity& entity );

  // Events callbacks
  virtual void onEnter            ( EEntity& entity, void *pUserData ) const {};
  virtual void onIsStillInside    ( EEntity& entity, void *pUserData ) const {};
  virtual void onLeave            ( EEntity& entity, void *pUserData ) const {};

  inline EPhActor* getPhActor     ( ) const { return m_pPhActor; }
  EPhActor&    createActor         ( EPhScene& scene );
  void         destroyActor       ( EPhScene& scene );
};

/*//------------------------------------------------------------
class EBoxEventShape : public EEventShape, public EBoxShape
{
public:
  EBoxEventShape( flag16 flagActivatedEventTypes, const EVector& vDimensions );
};*/

} // end namespace

#endif